<{include file="public/header.html"}>
<link rel="stylesheet" href="<{$style_dir}>/js/vendor/simditor/font-awesome.css" />
<script type="text/javascript" src="<{$style_dir}>/js/vendor/simditor/simditor.js"></script>
<!--发帖单页面-->
<div class="w1180-con mt20">
    <div class="post-article fl w840">
        <div class="classification mt20">
            <p class="title-big">任务分类</p>
            <ul id="tasks_cates_box" data-flag='<{if $act == 'add'}>0<{else}><{$task['cate_id']}><{/if}>'>
                <{foreach from=$cate_list key=key item=val}>
                <li <{if $val['cate_id'] == $task['cate_id']}>class='on'<{/if}>>
                <a href="javascript:void(0);" date-id="<{$val['cate_id']}>"><{$val['cate_name']}></a>
                </li>
                <{/foreach}>
            </ul>
            <div class="clear"></div>
        </div>

        <div class="title mt20" id="task_title">
            <p class="title-big">平台名称</p>
            <div class="title-box">
                <input type="text" name="post_plat_name" value="<{$task['plat_name']}>" <{if $level>=2}>readonly<{/if}>  id="post_plat_name" placeholder="平台名称不少于2个不大于10个字哦" maxlength="70" autofocus/>
            </div>
            <i class="mt5"><span class="title-count error">0</span>/50&nbsp;字</i>
        </div>
        <div class="title mt20" id="task_logo">
            <p class="title-big">平台logo</p>
            <div class="con-box">
                <input type="file" id="upload_picture_cover_id">
                <input type="hidden" name="logo" id="cover_id_cover_id" value="<{$task['logo']}>"/>
                <div class="upload-img-box">
                    <{if $task['logo']}>
                    <div class="upload-pre-item"><img src="<{$task['logo']}>" width="100"></div>
                    <{/if}>
                </div>
            </div>
            <i class="mt5">建议125px*40px</i>
            <script type="text/javascript" src="<{eval url()}>static/public/uploadify/jquery.uploadify.min.js"></script>
            <style>
                .uploadify-button {
                    border: 1px solid #e5e5e5;
                    border-radius: 5px;
                    font-size: 12px;
                    background: #efefef;
                    text-align: center;}
            </style>
            <script type="text/javascript">
                //上传图片
                /* 初始化上传插件 */
                $("#upload_picture_cover_id").uploadify({
                    "height"          : 30,
                    "swf"             : "<{eval url()}>static/public/uploadify/uploadify.swf",
                    "fileObjName"     : "picture",
                    "buttonText"      : "上传图片",
                    "uploader"        : "http://static.tan2.com/upload/picture.html",//
                    //'formData' : {"action": "upload", "sid" : ""},
                    "width"           : 100,
                    'removeTimeout'	  : 1,
                    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                    "onUploadSuccess" : uploadPicturecover_id,
                    'onFallback' : function() {
                        alert('未检测到兼容版本的Flash.');
                    }
                });
                function uploadPicturecover_id(file, data){
                    var data = $.parseJSON(data);
                    var src = '';
                    if(data.status){
                        $("#cover_id_cover_id").val(data.id);
                        src = data.url || '' + data.path
                        $("#cover_id_cover_id").parent().find('.upload-img-box').html(
                                '<div class="upload-pre-item"><img src="' + src + '" width="100"/></div>'
                        );
                    } else {
                        updateAlert(data.info);
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                            //$(that).removeClass('disabled').prop('disabled',false);
                        },1500);
                    }
                }
            </script>
        </div>
        <div class="con mt20" id="task_description">
            <p class="title-big">任务说明</p>
            <div class="con-box">
                <textarea name="description" id="post_description" placeholder="请在这里输入任务说明" style="resize: none;width: 100%;height: 100px;border: 1px solid #e5e5e5;"><{$task['description']}></textarea>
            </div>
        </div>
        <div class="con mt20" id="task_content">
            <p class="title-big">任务教程</p>
            <div class="con-box">
                <textarea id="post_content" name="post_content" placeholder="请在这里输入任务的详细操作内容"><{$task['content']}></textarea>
            </div>
            <i class="mt5"><span class="content-count error">0</span>&nbsp;字</i>
        </div>
        <div class="label mt20" id="task_task_tag">
            <p class="title-big">任务标签</p>
            <div class="label-list" id="tasks_tags_box">
                <{foreach from=$tags item=val}>
                <a href="javascript:void(0);" <{if in_array($val['name'],$task['task_tag'])}>class="on"<{/if}> data-name="<{$val['name']}>" data-tid="<{$val['id']}>"><{$val['name']}></a>
                <{/foreach}>
            </div>

            <div class="clear"></div>
            <div id="tasks_tags_error" style="display:none;"><label class="error f12">我们只接受2个标签哦~</label><label class="error f12">* 请选择标签</label></div>
        </div>
        <div class="label mt20" id="task_validate">
            <p class="title-big">验证条件</p>
            <div class="label-list" id="tasks_validate_box">
                <a href="javascript:void(0);" data-name="姓名" data-tid="1" <{if in_array(1,$task['validate'])}>class="on"<{/if}>>姓名</a>
                <a href="javascript:void(0);" data-name="身份证" data-tid="2" <{if in_array(2,$task['validate'])}>class="on"<{/if}>>身份证</a>
                <a href="javascript:void(0);" data-name="手机号" data-tid="3" <{if in_array(3,$task['validate'])}>class="on"<{/if}>>手机号</a>
            </div>
            <i class="mt5"></i>
            <div class="clear"></div>
        </div>
        <div class="title mt20" id="task_img_list">
            <script type="text/javascript" charset="utf-8" src="<{$style_dir}>/ueditor/ueditor.config.js"></script>
            <script type="text/javascript" charset="utf-8" src="<{$style_dir}>/ueditor/ueditor.all.min.js"> </script>
            <script id="Ueditor" type="text/plain"></script>
            <script>
                var _editor = UE.getEditor('Ueditor');
                _editor.ready(function () {
                    //设置编辑器不可用
                    //_editor.setDisabled();  这个地方要注意 一定要屏蔽
                    //隐藏编辑器，因为不会用到这个编辑器实例，所以要隐藏
                    _editor.hide();
                    //侦听图片上传
                    _editor.addListener('beforeinsertimage', function (t, arg) {
                        //将地址赋值给相应的input,只去第一张图片的路径
                        var imgs,imagehtml='';
                        for(var a in arg){
                            imagehtml += '<li style="float: left;"><img src="'+arg[a].src+'" alt="'+arg[a].alt+'" width="200"><input type="hidden" name="task_imglist[]" value="'+arg[a].src+'"/> </li>';
                        }
                        imagehtml += '<div class="clear"></div>';

                        //图片预览
                        $("#preview").append(imagehtml);
                    })

                });
                //弹出图片上传的对话框
                function upImage() {
                    var myImage = _editor.getDialog("insertimage");
                    myImage.open();
                }
            </script>
            <p class="title-big">截图示例</p>
            <div class="wd-content" style="width: 130px;">
                <div class="wd-operate" style="width: 90px;">
                    <a href="javascript:void(0);" onclick="upImage();"><b class="icon-com icon-adphoto"></b>添加图片</a>
                    <input class="easyui-textbox" type="hidden" id="picture" name="pic" value="" style="width:160px"/>
                </div>
            </div>
            <style>
                .ht_ul{
                    width: 100%;
                    height: auto;
                }
                .ht_ul li{
                    border: 1px solid #e5e5e5;
                    margin-right: 10px;
                }
            </style>
            <ul class="ht_ul" id="preview">
                <{if $task['img_list']}>
                <{foreach from=$task['img_list'] item=imgval}>
                <li style="float: left;"><img src="<{$imgval}>" width="200"><input type="hidden" name="task_imglist[]" value="<{$imgval}>"/> </li>
                <{/foreach}>
                <div class="clear"></div>
                <{/if}>
            </ul>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_sub_num">
            <p class="title-big">任务数量</p>
            <div class="title-box">
                <input type="text" name="subnum" id="post_subnum" <{if $level>=1}>readonly<{/if}> value="<{$task['sub_num']}>" placeholder="" onkeyup="this.value=this.value.replace(/\D/g,'')"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_commission">
            <p class="title-big">佣金</p>
            <div class="title-box">
                <input type="text" name="commission" id="post_commission" <{if $level>=1}>readonly<{/if}> value="<{$task['commission']}>" placeholder="请填写人民币，1人民币=10000溜溜币" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_ups_commission">
            <p class="title-big">推荐人佣金</p>
            <div class="title-box">
                <input type="text" name="ups_commission" id="post_ups_commission" <{if $level>=1}>readonly<{/if}> value="<{$task['ups_commission']}>" placeholder="请填写佣金百分数" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_hiups_commission">
            <p class="title-big">推荐人上级佣金</p>
            <div class="title-box">
                <input type="text" name="hiups_commission" id="post_hiups_commission" <{if $level>=1}>readonly<{/if}> value="<{$task['hiups_commission']}>" placeholder="请填写佣金百分数" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_commission_per">
            <p class="title-big">佣金比例</p>
            <div class="title-box">
                <input type="text" name="commission_per" id="post_commission_per" <{if $level>=1}>readonly<{/if}> value="<{$task['commission_per']}>" placeholder="请填写投资金额百分数" onkeyup="clearNoNum(this)" style="width: 95%;"/>
                <span>%</span>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_investment_money">
            <p class="title-big">投资金额</p>
            <div class="title-box">
                <input type="text" name="investment_money" id="post_investment_money" <{if $level>=1}>readonly<{/if}> value="<{$task['investment_money']}>" placeholder="请填写投资金额" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_investment_money_amount">
            <p class="title-big">投资总金额</p>
            <div class="title-box">
                <input type="text" name="investment_money_amount" id="post_investment_money_amount" <{if $level>=1}>readonly<{/if}> value="<{$task['investment_money']}>" placeholder="请填写总投资金额" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_min_investment_money">
            <p class="title-big">投资金额区间</p>
            <div class="title-box">
                <input type="text" name="min_investment_money" id="post_min_investment_money" <{if $level>=1}>readonly<{/if}> value="<{$task['min_investment_money']}>" placeholder="请填写投资金额区间最小值" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_max_investment_money">
            <p class="title-big">投资金额区间</p>
            <div class="title-box">
                <input type="text" name="max_investment_money" id="post_max_investment_money" <{if $level>=1}>readonly<{/if}> value="<{$task['max_investment_money']}>" placeholder="请填写投资金额区间最大值" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_investment_day">
            <p class="title-big">投资天数</p>
            <div class="title-box">
                <input type="text" name="investment_day" id="post_investment_day" <{if $level>=1}>readonly<{/if}> value="<{$task['investment_day']}>" placeholder="请填写投资天数" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_interest_rate">
            <p class="title-big">收益利率</p>
            <div class="title-box">
                <input type="text" name="interest_rate" id="post_interest_rate" <{if $level>=1}>readonly<{/if}> value="<{$task['interest_rate']}>" placeholder="请填写收益百分数" onkeyup="clearNoNum(this)" style="width: 95%;"/>
                <span>%</span>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_expected_money">
            <p class="title-big">预期收益</p>
            <div class="title-box">
                <input type="text" name="expected_money" id="post_expected_money" <{if $level>=1}>readonly<{/if}> value="<{$task['expected_money']}>" placeholder="请填写预期收益" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_bonus">
            <p class="title-big">红包</p>
            <div class="title-box">
                <input type="text" name="bonus" id="post_bonus" <{if $level>=1}>readonly<{/if}> value="<{$task['bonus']}>" placeholder="请填写红包金额" onkeyup="clearNoNum(this)"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_invite_code">
            <p class="title-big">邀请码</p>
            <div class="title-box">
                <input type="text" name="invite_code" id="post_invite_code" <{if $level>=1}>readonly<{/if}> value="<{$task['invite_code']}>" placeholder="请填写邀请码"/>
            </div>
            <i class="mt5"></i>
        </div>
        <div class="title" id="task_redirect_url">
            <p class="title-big">任务链接</p>
            <div class="title-box">
                <input type="text" name="redirect_url" id="post_redirect_url" <{if $level>=1}>readonly<{/if}> value="<{$task['redirect_url']}>" placeholder="请填写任务链接"/>
            </div>
            <i class="mt5"></i>
        </div>

        <div class="title" id="task_count_url">
            <p class="title-big">统计链接</p>
            <div class="title-box">
                <input type="text" name="count_url" id="post_count_url" <{if $level>=1}>readonly<{/if}> value="<{$task['count_url']}>" placeholder="请填写统计链接"/>
            </div>
            <i class="mt5"></i>
        </div>
        <script type="text/javascript">
            $(function() {
                var $preview, editor, mobileToolbar, toolbar;
                Simditor.locale = 'zh-CN';
                toolbar = ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'blockquote', '|', 'link', 'image', 'hr', '|','alignment'];
                var editor = new Simditor({
                    textarea: $('#post_content'),
                    toolbar: toolbar,
                    pasteImage: true,
                });
            });
        </script>

        <div class="post-btn mt20">
            <div id="draft_number" data-val="<{$draft_number}>" style="display:none;"></div>
            <input type="hidden" value="<{$task['tid']}>" id="post_tid"/>
            <input class="release fr ml20 _T_post_publish" type="submit" value="确认提交" data-action-url="<{if $act=='add'}><{eval url('task/add')}><{/if}><{if $act=='edit'}><{eval url('task/update')}><{/if}>" data-unvalid="提交中..."/>

        </div>
    </div>
    <{include file="post/right.html"}>
</div>


<script type="text/javascript">
    $(function(){
        if('<{$login}>' == '1'){
            showLogin('login');return;
        }else{
            if('<{$mobile}>'=='0'){
                layer.msg("发布前请到官网个人中心填写手机号!",{icon:0,offset:300,time:2000},function(){window.location.href='/user/security.html#change-phone'});
            }else{
                if("<{$cate_code}>" == "" || "<{$sec_cate_code}>" == "" ){
                    $(".popup-post").fadeIn();
                    $(".popup").fadeIn();
                }
            }
        }
        $('.post-article .label .add-btn').on('click',function(){
            $(this).parents('.label').find('.label-input').toggle(500);
        });
        $('.post-article .tip-mail .checkbox').on('click',function(){
            $(this).hasClass('active') ? $(this).removeClass('active') : $(this).addClass('active');
        });
    });
</script>
<script type="text/javascript" src="<{$style_dir}>/js/post.task2.js"></script>
<script>
    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数

    }
</script>
<!--底部-->
<{include file="public/footer.html"}>